package com.game.manager;

import java.nio.ByteBuffer;

import org.apache.log4j.Logger;
import org.phprpc.util.PHPSerializer;
import org.xsocket.connection.INonBlockingConnection;

import com.command.Group;
import com.connect.agreement.Packet;

public class ErrorManager {
	public static final int EditorError = 1000;
	
	public static final int NonRole = 1001;
	public static final int SendPacket = 1002;
	public static final int SencondConnKickOut = 1003;
	public static final int FouseToOfflineFailed = 1004;
	public static final int SqlError = 1005;
	
	public static void sendError(INonBlockingConnection nbc,int error){
		Packet packet = new Packet();
		try {
			packet.setBuffer(Group.Error, (byte)1, new PHPSerializer().serialize(error),true);
			nbc.write(packet.byteBuffer());			
		} catch (Exception e) {
			e.printStackTrace();
			Logger.getRootLogger().info("Warning:发送Error给"+nbc.getRemoteAddress()+"："+e.getMessage());
		}
	}
	
	public static void sendErrorMsg(INonBlockingConnection nbc, String str){
		Packet packet = new Packet();
		try {
			packet.setBuffer(Group.Error, (byte)2, new PHPSerializer().serialize(str),true);
			nbc.write(packet.byteBuffer());			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
